<div class="w-box w-box-padd prl-panel">
    <h4>บทความที่เกี่ยวข้อง</h4>
    <div class="prl-grid prl-grid-divider">
	<?php 
	$sql = "SELECT * FROM article WHERE fix_status = 1 AND fix_article_type =".$type." ORDER BY reader_count DESC LIMIT 3";
	$rsd = mysql_query($sql);
	while($row = mysql_fetch_array($rsd))
	{
		$date = new DateTime($row['inserted_date_time']);
	?>
        <div class="prl-span-4">
            <article class="prl-article">
            	<a class="prl-thumbnail" href="single.php?id=<?php echo $row["article_id"]?>" target="_blank">
                    <span class="prl-overlay">
						 <?php
							if((bool)preg_match('#<img[^>]+src=[\'"]([^\'"]+)[\'"]#', html_entity_decode($row['description']), $matches))
							{
							   $imageFound = $matches[0];
							   $src = substr($imageFound, strpos($imageFound, "src"));
							}
							else
							{
							  $src = "src=\"images/default_image.png\"";
							}
						 ?>
                         <img <?php echo $src;?> alt="Patani Forum">
                        <span class="prl-overlay-area o-file"></span>
                    </span>
            	</a>
                <h5><a href="single.php?id=<?php echo $row["article_id"]?>" target="_blank"><?php echo $row["title"]?></a></h5> 
                <div class="prl-article-meta"><span><i class="fa fa-clock-o"></i> <?php echo $date->format('d/m/Y H:i:s');?></span></div>
            </article>
        </div>
	<?php }?>
    </div>
</div>    